package co2.bean;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import co2.engine.DAOInterface;
import co2.pojos.PR;


@ManagedBean
@ViewScoped
public class PrBean extends AbstractBean implements Serializable {
	private static final long serialVersionUID = 1L;
	private PR pr;
	
	@Autowired
	@Qualifier("daoI")
	private DAOInterface dao;
	
	@PostConstruct
	public void postCon(){
		pr = new PR();
	}

	public void save(){
		try{
			dao.save(pr);
			postCon();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void update(){
		try{
			dao.update(pr);
			postCon();
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void delete(){
		try{
			dao.delete(PR.class, pr.getId());
			postCon();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
